#include "./standartitembuilder.h"

StandartItemBuilder::StandartItemBuilder()
{
}

void StandartItemBuilder::_prepareRow(QSqlRecord record, QVector<QStandardItem*> &result)
{

    QStandardItem* item = new QStandardItem(record.value(0).toString());
    item->setData(_globalId);
    item->setEditable(false);
    result << item;
}


QVector<QStandardItem *> StandartItemBuilder::build()
{
    QVector<QStandardItem*> result;
    if(!_model.isNull())
    {
        _model->setFilter(_modelFilter);
        _model->select();

        for(int i=0; i<_model->rowCount(); i++)
        {
            QSqlRecord record = _model->record(i);
            _prepareRow(record, result);
        }
    }
    else
    {
        _prepareRow(_rowRecord[0], result);
    }

    return result;
}

